package com.zelix;

import java.awt.*;
import java.util.StringTokenizer;
import java.util.Vector;

public final class a extends Canvas {

    static int a;
    private String b;
    private int c;
    private FontMetrics d;
    private int e;
    private int f;
    private Vector g;
    private boolean h;
    private static String z;

    public a(String s, int i, Font font) {
        b = s;
        c = i;
        setFont(font);
        d = getFontMetrics(getFont());
        e = d.getAscent();
        f = d.getDescent();
    }

    public Dimension getMinimumSize() {
        return new Dimension(c, a());
    }

    public int a() {
        int i;
        label0:
        {
            if (!h)
                b();
            if (g == null) {
                i = 0;
                if (!g2.b)
                    break label0;
            }
            i = g.size() * (e + f + a);
        }
        return i;
    }

    public Dimension getPreferredSize() {
        return getMinimumSize();
    }

    public void invalidate() {
        super.invalidate();
        h = false;
    }

    void b() {
        StringTokenizer stringtokenizer;
        StringBuffer stringbuffer;
        int i;
        int j;
        int k;
        boolean flag;
        flag = g2.b;
        g = new Vector();
        stringtokenizer = new StringTokenizer(b, z, true);
        stringbuffer = new StringBuffer();
        i = 0;
        j = stringtokenizer.countTokens();
        k = 0;
        for (; k < j; k++) {
            String s = stringtokenizer.nextToken();
            if (s.equals("\n") || s.equals("\r")) {
                g.addElement(stringbuffer.toString());
                stringbuffer = new StringBuffer();
                i = 0;
                if (flag) {
                    int l = d.stringWidth(s);
                    i += l;
                    if (i <= c) {
                        stringbuffer.append(s);
                        if (flag) {
                            g.addElement(stringbuffer.toString());
                            stringbuffer = new StringBuffer();
                            if (!s.equals(" ")) {
                                stringbuffer.append(s);
                                i = l;
                                if (flag) {
                                    i = 0;
                                    if (k == j - 1)
                                        g.addElement(stringbuffer.toString());
                                    h = true;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    public void paint(Graphics g1) {
        int i;
        int j;
        boolean flag;
        flag = g2.b;
        if (!h)
            b();
        Dimension dimension = getSize();
        g1.clearRect(0, 0, dimension.width, dimension.height);
        i = e;
        j = 0;
        for (; j < g.size(); j++) {
            String s = (String) g.elementAt(j);
            g1.drawString(s, 0, i);
            i += e + f + a;
        }
    }

    public synchronized void setBounds(int i, int j, int k, int l) {
        super.setBounds(i, j, k, l);
        c = getSize().width;
    }

    public void update(Graphics g1) {
        paint(g1);
    }

    public void validate() {
        super.validate();
        repaint();
    }

    private static String z(char ac[]) {
        for (int i = 0; i < ac.length; i++) {
            byte key = 0;
            switch (i % 5) {
                case 0:
                    key = 9;
                    break;
                case 1:
                    key = 106;
                    break;
                case 2:
                    key = 46;
                    break;
                case 3:
                    key = 87;
                    break;
                default:
                    key = 68;
                    break;
            }
            ac[i] ^= key;
        }
        return new String(ac).intern();
    }

    static {
        z = z(")`#".toCharArray());
        a = 1;
    }
}